apiready = function() {
seajs.use(['../../V',"../../api","../../jquery","../../app","../../service","../../swiper","../../dialog"],function(V,$api,$,app,service,Swiper,dialog){
  var el = document.querySelector('.container');
  var vm = {
    el: el,
    data: {
      hotList: []
    },
    created: function () {
      this.init();
    },
    methods: {
      init: function () {
        this.getHot();
      },

      // 获取热门搜索词条
      getHot: function () {
        var that = this;
        app.ajax(
          service['searchRecommend'],
          {
            data: {
              values: {}
            }
          },
          function (res) {
            if (res.code == 0) {
              that.hotList = res.data;
            } else {
              api.toast({
                  msg: res.message,
                  duration: 2000,
                  location: 'bottom'
              });
            }
          }
        );
      },

      // 搜索热门词条
      searchHot: function (e) {
        var searchId = e.target.dataset.id;
        var val = e.target.innerText;
        app.openWin('searchDetail', {searchVal: val});
      },

      // 搜索
      search: function () {
        var val = $('#search-val').val();
        if (val == '' || val == null) {
          api.toast({
              msg: '请输入搜索内容',
              duration: 2000,
              location: 'middle'
          });
          return;
        }
        app.openWin('searchDetail', {searchVal: val});

      },

      // 搜索分享商品id
      search_share: function () {
        var val = $('#search-val-share').val();
        if (val == '' || val == null) {
          api.toast({
              msg: '请输入搜索内容',
              duration: 2000,
              location: 'middle'
          });
          return;
        }

        var that = this;
        app.ajax(
          service['shareSearch'],
          {
            data: {
              values: {
                search_key: val
              }
            }
          },
          function (res) {
            if (res.code == 0) {
              if (res.data.type == 1) {
                var otherUserId = res.data.shop_user_id;
                app.ajax(
      						service['shopDetail'],
      						{
      							data: {
      								values: {
      									appid: app.appid,
      									userid: otherUserId
      								}
      							}
      						},
      						function (rel) {
      							if (rel.code == 0) {
      								var shopInfo = rel.data;
      								app.openWin('buyMain', {shopData: shopInfo, otherUserInfoId: otherUserId});
      							} else {
      								api.toast({
      								    msg: rel.message,
      								    duration: 2000,
      								    location: 'bottom'
      								});
      							}
      						}
      					)
              } else if (res.data.type == 2) {
                var goodsId = res.data.goods_id;
                app.openWin('buyGoods', {goodsId: goodsId});
              } else if (res.data.type == 3) {
                var goodsId = res.data.goods_id;
                app.openWin('groupBuyDetail', {goodsId: goodsId});
              }
            } else {
              api.toast({
                  msg: res.message,
                  duration: 2000,
                  location: 'bottom'
              });
            }
          }
        );
      }
    }
  }
  var even = function() {}
  var newVue = new Vue(vm);
  even();
})
}
